package com.frogs.ucenter.service.daoimpl;

import javax.annotation.Resource;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.frogs.framework.base.dao.BaseDao;
import com.frogs.framework.base.service.daoimpl.BaseServiceImpl;
import com.frogs.ucenter.component.RequestApiHelper;
import com.frogs.ucenter.dao.IntegralPromotionGoodsRelationDao;
import com.frogs.ucenter.entity.IntegralPromotionGoodsRelation;
import com.frogs.ucenter.service.IntegralPromotionGoodsRelationService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class) 
@Service("integralPromotionGoodsRelationService")
public class IntegralPromotionGoodsRelationServiceImpl extends BaseServiceImpl<IntegralPromotionGoodsRelation> implements IntegralPromotionGoodsRelationService {
    @Autowired
    private IntegralPromotionGoodsRelationDao integralPromotionGoodsRelationDao;
    
	@Resource(name="requestApiHelper")
	private RequestApiHelper apiHelper;

    public IntegralPromotionGoodsRelationServiceImpl() {
        super();
    }

    public IntegralPromotionGoodsRelationDao getIntegralPromotionGoodsRelationDao() {
        return integralPromotionGoodsRelationDao;
    }

    /**
     * Don't remove or edit it.
     */
    @Override
    protected BaseDao<IntegralPromotionGoodsRelation> getBaseDao() {
        return integralPromotionGoodsRelationDao;
    }

    public void setIntegralPromotionGoodsRelationDao(IntegralPromotionGoodsRelationDao integralPromotionGoodsRelationDao) {
        this.integralPromotionGoodsRelationDao = integralPromotionGoodsRelationDao;
    }

	@Override
	public JSONArray getPromotionList(int sendCardType, int pageNo, int pageSize) {
		JSONObject json= apiHelper.getPromotionCouponList(sendCardType, pageNo, pageSize);
		JSONArray ja = json.getJSONObject("response").getJSONArray("list");
		return ja;
	}
}